﻿<%@ page language="java" import="java.util.*,java.util.Map.*,cn.ac.cintcm.dataconverge.researcher.domain.*,cn.ac.cintcm.dataconverge.researchsubject.domain.*" pageEncoding="UTF-8"%>
<%@page import="com.hs.core.page.PageUtil,com.hs.core.utils.*"%>
<%@page import="cn.ac.cintcm.dataconverge.util.Constants,cn.ac.cintcm.dataconverge.util.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
PageUtil pageUtil = (PageUtil)request.getAttribute("middleCheckList");
List resultList = null;
String pageStr = ""; 
int perpageCount = 1;
int currentPage = 1;
if(null != pageUtil){
   resultList = pageUtil.getPageList();
   pageStr = pageUtil.getPageStr();
   perpageCount = pageUtil.getNumberPerPage();
   currentPage = pageUtil.getCurrentPage();
}
String subjectname = (String)request.getAttribute("subjectname");
String startdate = (String)request.getAttribute("startdate");
String enddate = (String)request.getAttribute("enddate");
String startyear = (String)request.getAttribute("startyear");
String endyear = (String)request.getAttribute("endyear");
String snumber = (String)request.getAttribute("snumber");
String status = (String)request.getAttribute("status");

String onreserach = (String)request.getAttribute("onreserach");
String onpermit = (String)request.getAttribute("onpermit");
String finishSubject = (String)request.getAttribute("finishSubject");

String orderName = (String)request.getAttribute("orderName");
String orderNum = (String)request.getAttribute("orderNum"); 

Researcher researcher = (Researcher) request.getSession().getAttribute(
		Constants.USER_IN_SESSION);
boolean isAdmin = AuthCheck.isAdmin(researcher);
boolean isOrgLeader = AuthCheck.isInGroup(request,Constants.ORG_LEADER);
boolean flag = false;
if(isAdmin || isOrgLeader)
	flag = true;

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>课题信息</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> 
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <link href="<%=path%>/index/Themes/com/style.css" rel="stylesheet" type="text/css" /> 
    <script src="<%=path%>/index/Scripts/Script.js" language="javascript" type="text/javascript"></script>
     <script src="<%=path%>/js/common.js" language="javascript" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
     <script src='<%=basePath%>dwr/engine.js'></script>
     <script src='<%=basePath%>dwr/util.js'></script> 
     <script src='<%=basePath%>dwr/interface/subject.js'></script>
    <script language="javascript" type="text/javascript">
    
       function searchSubject(){ 
       			searchform.submit();			
       }
       function finishCheck(id,checkresult){
          var userId = '<%=researcher.getIds()%>';
               subject.finishCheck(id,userId,"",checkresult,callBackForFinish);
       }
       function callBackForFinish(data){
          alert(data);
         // window.location.replace(window.location.href);
          document.pageForm.submit(); 
           
       }
       function deleteCheck(id){ 
          subject.deleteCheck(id,callBackForDelete);
       }
       function callBackForDelete(data){
       	  var data = "删除成功";
          alert(data); 
          document.pageForm.submit(); 
           
       }
    </script>
 
</head>
<body class="rtm_body" scroll=yes>
<form name="searchform" action = "<%=path%>/checkManage.htm?action=listMiddleCheckList" method="post">
 
    <div class="r_rtm_tb_mg1">
        <div class="r_rtm_tb1">
            <span>
                <img src="<%=path%>/index/Themes/com/idt_tb_pass.gif" />&nbsp;&nbsp;中期检查课题查询</span>
        </div>
    </div>    
       
     <table cellspacing="2" cellpadding="0" width="100%" class="idt_item_mg" id="Table2">
        <tr>
            <td class="fim_l">
                课题名称：</td>
            <td class="fim_r">
                <input type="text" name="subjectname" value="<%=subjectname==null?"":subjectname %>" class="com_textbox" ></td>
            <!-- <td class="fim_l">
                申报日期：</td>
            <td class="fim_r" nowrap width="30%">
                从
               <input type="text" class="Wdate" id="startdate" value="<%=startdate==null?"":startdate %>" style="width:40%" name="startdate"  onFocus="WdatePicker({el:'startdate',dateFmt:'yyyy-MM-dd'})" />
                &nbsp;至
               <input type="text" class="Wdate" id="enddate" value="<%=enddate==null?"":enddate %>" style="width:40%" name="enddate"  onFocus="WdatePicker({el:'enddate',dateFmt:'yyyy-MM-dd'})" />
            </td>-->
             <td class="fim_l">
                课题状态：</td>
            <td class="fim_r" nowrap width="20%">
               <select name="status" style="width:100%">
                 <option value="-1">----请选择----</option>
                  <option value="<%=Constants.subject_state_save%>" <%if((""+Constants.subject_state_save).equals(status)){out.println(" selected");} %>>未提交审批</option>
                 <option value="<%=Constants.subject_state_apply%>" <%if((""+Constants.subject_state_apply).equals(status)){out.println(" selected");} %>>申报中</option>
                  <option value="<%=Constants.subject_state_advised%>" <%if((""+Constants.subject_state_advised).equals(status)){out.println(" selected");} %>>推荐中标</option>
                   <option value="<%=Constants.subject_state_checked%>" <%if((""+Constants.subject_state_checked).equals(status)){out.println(" selected");} %>>中标</option>
                  <option value="<%=Constants.subject_state_researching%>" <%if((""+Constants.subject_state_researching).equals(status)){out.println(" selected");} %>>在研</option>
                 <option value="<%=Constants.subject_state_endApply%>" <%if((""+Constants.subject_state_endApply).equals(status)){out.println(" selected");} %>>申请结题</option>
                
                   <option value="<%=Constants.subject_state_ended%>" <%if((""+Constants.subject_state_ended).equals(status)){out.println(" selected");} %>>已结题</option>
                   <option value="<%=Constants.subject_state_unchecked%>" <%if((""+Constants.subject_state_unchecked).equals(status)){out.println(" selected");} %>>未中标</option>
                   <option value="<%=Constants.subject_state_retuen%>" <%if((""+Constants.subject_state_retuen).equals(status)){out.println(" selected");} %>>退回修改</option>
                 
                </select>  
            </td>
            <td class="fim_r" align="right" colspan="2">
                <input type="button" value="查询"  onclick="searchSubject()" class="com_btn2" id="Button5">
                <input type="button" value="高级查询"   onclick="if(AdCheckForm.style.display=='none')AdCheckForm.style.display='';else AdCheckForm.style.display='none';"
                    class="com_btn2" id="Button1">
                
            </td>
        </tr>
        <tr id="AdCheckForm" style="display: none;">
            <td class="fim_l">
                课题编号：</td>
            <td class="fim_r">
                <input type="text" class="com_textbox" id="snumber" value="<%=snumber==null?"":snumber %>" name="snumber"></td>
            <td class="fim_l">
                所属年份：</td>
            <td class="fim_r">
                从
               <input type="text" class="Wdate" id="startyear" value="<%=startyear==null?"":startyear %>" style="width:40%" name="startyear"  onFocus="WdatePicker({el:'startyear',dateFmt:'yyyy'})" />
                &nbsp;至
               <input type="text" class="Wdate" id="endyear" value="<%=endyear==null?"":endyear %>" style="width:40%" name="endyear"  onFocus="WdatePicker({el:'endyear',dateFmt:'yyyy'})" />
            </td>
            <td class="fim_l">
                当前状态：</td>
            <td class="fim_r"> 
                <select name="status">
                 <option value="-1">----请选择----</option>
                 <option value="0" <%if("0".equals(status)){out.println(" selected");} %>>未检查</option>
                 <option value="1" <%if("1".equals(status)){out.println(" selected");} %>>已检查</option>
                 
                </select>     
            </td>
        </tr>
        </form>
    </table> 
   
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td>
                <div class="content">
                 <form name="form1" action="" method="post">
                    <table width="*" cellpadding="0" cellspacing="1" class="dg_borderstyle" id="Table4"> 
                        <tr> 
                            
                                
                            <td class="dg_headerstyle" width="10%">
                                 <a href="javaScript:orderPage('snumber','<%=OrderTool.getOrderNum("snumber",orderName,orderNum)%>');">课题编号&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("snumber",orderName,orderNum))%></a></td>
                            <td class="dg_headerstyle" width="20%">
                                <a href="javaScript:orderPage('subjectname','<%=OrderTool.getOrderNum("subjectname",orderName,orderNum)%>');">课题名称&nbsp;&nbsp;<%=OrderTool.getOrderImage(basePath,OrderTool.getOrderNum("subjectname",orderName,orderNum))%></a></td>
                             <td class="dg_headerstyle">
                                计划开始日期</td> 
                                  <td class="dg_headerstyle">
                                计划结束日期</td>
                                 <td class="dg_headerstyle">
                                提醒类别 </td> 
                                <td class="dg_headerstyle">
                                中期检查开始日期</td>
                                <td class="dg_headerstyle">
                                中期检查完成日期</td>
                             
                                
                                <td class="dg_headerstyle">
                                当前状态</td> 
                                <td class="dg_headerstyle">
                                中期检查结果</td> 
                                 <td class="dg_headerstyle">
                                检查人</td>
                               <%if(flag){ %>
                                <td class="dg_headerstyle">
                                中期检查</td> 
                                <%} %>
                                 <td class="dg_headerstyle">
                                操作</td>
                        </tr>
                        <%if(null != resultList && resultList.size()> 0){
                        	Map subjectMap = new HashMap();
                        	for(int i = 0;i < resultList.size();i++){
                        		 ResmanSubjectCheck obj = (ResmanSubjectCheck)resultList.get(i); 
                        		 String subjectId = obj.getSubject().getId()+"";
                        		 Map set = null;
                        		 List list = null;
                        		 if(null == subjectMap.get(subjectId)){
                        			 set = new HashMap(); 
                        			 set.put(subjectId,obj.getSubject());
                        			 list = new ArrayList();
                        			 list.add(obj);
                        			 set.put("dataList",list);
                        		 }else{
                        			 set = (HashMap)subjectMap.get(subjectId);
                        			 set.put(subjectId,obj.getSubject());
                        			 list = (ArrayList)set.get("dataList");
                        			 list.add(obj);
                        		 } 
                        		 subjectMap.put(subjectId,set); 
                        	}
                        	
                        	Set objset = subjectMap.entrySet();
                        	Iterator iter = objset.iterator();
                        	int i = 0;
                            while(iter.hasNext())
                            {    
                            	 i++;
                            	 Entry entry = (Entry)iter.next();
                            	 String subjectkey = (String)entry.getKey();
                            	 Map treeSet = (HashMap)entry.getValue();
                            	 Subject subject = (Subject)treeSet.get(subjectkey);
                            	
                            	 List objlist = (ArrayList)treeSet.get("dataList"); 
                            	 int size = objlist.size();
                             
                         %>
                        <tr class="dg_alternatingitemstyle" onmouseover="ChangeRowBg(this);" onmouseout="ChangeRowBg(this);" onmouseup="ChangeRowBg(this);" onmousedown="ChangeRowBg(this);">
                           
                            <td align="center" rowspan="<%=size%>">
                               <%=StringUtilTool.NULL2Blank(subject.getSnumber()) %>
                            </td>
                            <td rowspan="<%=size%>">
                                 <a href="#"   onclick="openwindow('<%=path %>/subjectToAdd.htm?action=viewSubject&id=<%=subject.getId() %>','','','')"> <%=StringUtilTool.NULL2Blank(subject.getSubjectname()) %></a>
                            </td> 
                            <td rowspan="<%=size%>">
                                <%=Tools.getDateStringByDate1(subject.getStartdate()) %>
                            </td> 
                            <td rowspan="<%=size%>">
                                 <%=Tools.getDateStringByDate1(subject.getEnddate()) %>
                            </td> 
                           
                             <% 
                             int index = 0;
                             for(int k = 0;k < objlist.size();k++){
                            	  index++;
                            	  ResmanSubjectCheck obj = (ResmanSubjectCheck)objlist.get(k);
                            	  if( index == 1){
                            	  
                             %>
                            <td align="center">
							<%
							 if("1".equals(obj.getAlertType()+"")){ 
								 out.print("<font color=red>自动提醒</font>");
							 }
							 if("2".equals(obj.getAlertType()+"")){ 
								 out.print("<font color=red>设置提醒</font>");
							 }
							
							%>
                            </td>
                            
                             <td>
                                 <%=Tools.getDateStringByDate1(obj.getStartdate()) %>
                            </td> 
                            <td>
                                 <%=Tools.getDateStringByDate1(obj.getEnddate()) %>
                            </td> 
                            
                            <td> <font color="red"> 
                                 <%
                                   if("0".equals(obj.getCheckstatus()+""))
                                	   out.print("未检查");
                                   if("1".equals(obj.getCheckstatus()+""))
                              	       out.print("已检查");
                                 
                                 %>
                                   </font>
                            </td> 
                            <td>
                                 <font color="red"> <%
                                   if("1".equals(obj.getCheckresult()+""))
                                	   out.print("未通过");
                                   if("2".equals(obj.getCheckresult()+""))
                              	       out.print("已通过");
                                 
                                 %>
                                 </font>
                            </td> 
                             <td align="center">
                                 <%=obj.getCheckuserid()==null?"":obj.getCheckuserid().getName() %>
                            </td> 
                             <%if(flag){ %>
                            <td align="center">
                                 <%
                                 if("2".equals(obj.getCheckresult()+"")) {
                                	 %>
                                	 <a href="javaScript:finishCheck(<%=obj.getId() %>,'1');"> 不通过 </a>
                                 <%}else{%>
                                     <a href="javaScript:finishCheck(<%=obj.getId() %>,'2');">通过</a>
                                 <%} %>
                                 
                            </td> 
                            <td align="center">
                                <a href="javaScript:deleteCheck(<%=obj.getId() %>);">删除</a>
                             </td>
                            <%} %>
                             
                        </tr> 
                         <%}else{%>
                       <tr class="dg_alternatingitemstyle" onmouseover="ChangeRowBg(this);" onmouseout="ChangeRowBg(this);" onmouseup="ChangeRowBg(this);" onmousedown="ChangeRowBg(this);">
                           <td align="center">
                                
							<%
							 if("1".equals(obj.getAlertType()+"")){ 
								 out.print("<font color=red>自动提醒</font>");
							 }
							 if("2".equals(obj.getAlertType()+"")){ 
								 out.print("<font color=red>设置提醒</font>");
							 }
							
							%>
                            </td>
                            
                             <td>
                                 <%=Tools.getDateStringByDate1(obj.getStartdate()) %>
                            </td> 
                            <td>
                                 <%=Tools.getDateStringByDate1(obj.getEnddate()) %>
                            </td> 
                            
                            <td> <font color="red"> 
                                 <%
                                   if("0".equals(obj.getCheckstatus()+""))
                                	   out.print("未检查");
                                   if("1".equals(obj.getCheckstatus()+""))
                              	       out.print("已检查");
                                 
                                 %>
                                   </font>
                            </td> 
                            <td>
                                 <font color="red"> <%
                                   if("1".equals(obj.getCheckresult()+""))
                                	   out.print("未通过");
                                   if("2".equals(obj.getCheckresult()+""))
                              	       out.print("已通过");
                                 
                                 %>
                                 </font>
                            </td> 
                             <td align="center">
                                 <%=obj.getCheckuserid()==null?"":obj.getCheckuserid().getName() %>
                            </td> 
                             <%if(flag){ %>
                            <td align="center">
                                 <%
                                 if("2".equals(obj.getCheckresult()+"")) {
                                	 %>
                                	 <a href="javaScript:finishCheck(<%=obj.getId() %>,'1');"> 不通过 </a>
                                 <%}else{%>
                                     <a href="javaScript:finishCheck(<%=obj.getId() %>,'2');">通过</a>
                                 <%} %>
                            </td> 
                             <td align="center">
                                <a href="javaScript:deleteCheck(<%=obj.getId() %>);">删除</a>
                             </td>
                            <%} %>
                        </tr> 
                        <% }}}}else{%>
                         <tr class="dg_alternatingitemstyle"> 
                            <td align="center" colspan=17>
                                <font color="red">没有找到记录</font>
                            </td> 
                        </tr> 
                        <%}%>
                    </table>
                    </form>
                    <div class="dg_pagerstyle" align="right"> 
                            <%=pageStr %>  
                    </div> 
                </div>
            </td>
        </tr>
    </table>
</body>
</html>
